Vercel
API ReferenceChats

Update Chat Files

Creates, updates, or deletes files for a chat. Pass null to delete. This requires the chat's preview to be running.

PATCH/v2/chats/{chatId}/files

Usage

TypeScript Example
import { v0 } from 'v0-sdk'const result = await v0.chats.updateFiles({  chatId: 'chat_abc123',  files: 'example',})console.log(result)

API Signature

Request

Path Parameters

chatId: string

The unique identifier of the chat.

Request Body

files: object[]

The files to create, update, or delete. Each path must be unique.

path: string

Project-relative file path, e.g. "app/page.tsx".

content: string | null

New file content. Pass null to delete the file at this path.

Response

messages: object[]

The user and assistant messages created by the edit, in chronological order.

id: string

Unique message identifier.

chatId: string

ID of the chat this message belongs to.

role: 'user' | 'assistant'

Who produced this message.

createdAt: string

ISO timestamp when the message was created.

updatedAt: string

ISO timestamp when the message was last updated.

content: string

The trailing prose of the message — the agent’s closing summary, or the user’s message text. Empty string when there is no closing prose.

parts: ('text' | 'thinking' | 'file-read' | 'file-edit' | 'search' | 'bash' | 'tool-call' | 'agent-action')[]

Ordered list of parts that make up the message. Iterate to render the full narrative including thinking, file operations, tool calls, and prose.

type: 'text'

A block of text output by the agent.

text: string

Markdown prose written by the agent or user.

startedAt?: string

ISO timestamp when this part began.

finishedAt?: string

ISO timestamp when this part completed.

finishReason: 'stop' | 'length' | 'content-filter' | 'tool-calls' | 'error' | 'other' | null

Why generation ended. Null while the agent is still generating; once non-null, the message is final and safe to consume.

attachments?: object[]

Files attached to this message.

url: string

URL to the attachment.

name?: string

Original filename, when available.

contentType?: string

MIME type.

size?: integer

Size in bytes.

authorId: string | null

ID of the user who authored a user message; null for assistant messages.

usage: object

Token usage and credit cost. All values are zero on user messages and on assistant messages that have not yet generated tokens.

tokens: object

Token counts for this message.

input: number

Prompt input value (non-cached).

output: number

Completion output value.

cacheRead: number

Cache-read input value.

cacheWrite: number

Cache-write input value.

total: number

Sum of input, output, cacheRead, and cacheWrite.

creditsCost: object

Credit cost for this message.

input: number

Prompt input value (non-cached).

output: number

Completion output value.

cacheRead: number

Cache-read input value.

cacheWrite: number

Cache-write input value.

total: number

Sum of input, output, cacheRead, and cacheWrite.

On this page